package itsm.isperp.module.entity.app;

import itsm.isperp.framework.domain.BaseBean;
import itsm.isperp.framework.message.domain.IMessagePacket;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * 系统信息
 * 
 * @author lizx
 * @date 2013-7-29
 */
@Entity
@Table(name = "app_message")
public class AppMessage extends BaseBean implements IMessagePacket {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Column
	protected String receiverId;

	@Column
	protected String receiverAddress;

	@Column
	protected String title;

	@Column
	protected String content;

	@Column
	protected String messageType;

	@Column
	protected Integer messageLevel;

	@Column
	protected int failCount;

	@Column
	protected String senderId;

	@Column
	protected String sourceId;

	public AppMessage() {
	}

	public AppMessage(IMessagePacket msg) {

		this.id = msg.getId();
		this.title = msg.getTitle();
		this.content = msg.getContent();
		this.failCount = 0;
		this.messageLevel = 1;
		this.receiverId = msg.getReceiver();
		this.receiverAddress = msg.getReceiverAddress();
		this.messageType = msg.getMessageType();
		this.sourceId = msg.getSourceId();

		this.senderId = msg.getSender();
	}

	public AppMessage(AppMessage msg) {
		this.id = msg.getId();
		this.title = msg.getTitle();
		this.content = msg.getContent();
		this.failCount = msg.getFailCount() + 1;
		this.messageLevel = msg.getMessageLevel();
		this.receiverId = msg.getReceiverId();
		this.receiverAddress = msg.getReceiverAddress();
		this.messageType = msg.getMessageType();
		this.sourceId = msg.getSourceId();
		this.senderId = msg.getSender();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getReceiverId() {
		return receiverId;
	}

	public void setReceiverId(String receiverId) {
		this.receiverId = receiverId;
	}

	public String getReceiverAddress() {
		return receiverAddress;
	}

	public void setReceiverAddress(String receiverAddress) {
		this.receiverAddress = receiverAddress;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getMessageType() {
		return messageType;
	}

	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}

	public Integer getMessageLevel() {
		return messageLevel;
	}

	public void setMessageLevel(Integer messageLevel) {
		this.messageLevel = messageLevel;
	}

	public int getFailCount() {
		return failCount;
	}

	public void setFailCount(int failCount) {
		this.failCount = failCount;
	}

	public String getSenderId() {
		return senderId;
	}

	public void setSenderId(String senderId) {
		this.senderId = senderId;
	}

	public String getSourceId() {
		return sourceId;
	}

	public void setSourceId(String sourceId) {
		this.sourceId = sourceId;
	}

	@Override
	public String getReceiver() {
		return receiverId;
	}

	@Override
	public void setReceiver(String receiver) {
		this.receiverId = receiver;
	}

	@Override
	public String getSender() {
		return senderId;
	}

	@Override
	public void setSender(String sender) {
		this.senderId = sender;
	}

}
